//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    imgUrls: [
      'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 6000,
    duration: 100,
    video: {},
    video1:'http://image.niuduxiu.com/video/2017/12/27/9c4ec7c6-8e9b-46fa-a7d2-b27a62af2dbd.mp4',
    zixunArray:[],
    huodongArray:[],
    kechengArray:[],
    teacherArray:[]
  },
  onLoad: function (options) {
    wx.request({
      url: 'https://www.citycreate.cn/bbj/wx/marquee/list-dcd8657b00b841bb93f21de7a7c40f30.html',
      success:(item)=>{
        this.setData({
          imgUrls:item.data.data
        })
      }
    })
    wx.request({
      url: 'https://www.citycreate.cn/bbj/wx/marquee/list-4b66c8d122a6492482b7456cdc7d58d0.html',
      success: (item) => {
        this.setData({
          video: item.data.data[0].videoPath
        })
      }
    })
    var that = this
    wx.request({
      url: 'https://www.citycreate.cn/bbj/wx/article/list-3.html',
      data: {
        pageNo: 1,
        pageSize: 4
      },
      success: function (res) {
        that.setData({
          zixunArray: res.data.data.list,
        })
      }
    })
    wx.request({
      url: 'https://www.citycreate.cn/bbj/wx/article/list-4.html',
      data: {
        pageNo: 1,
        pageSize: 4
      },
      success: function (res) {
        that.setData({
          huodongArray: res.data.data.list,
        })
      }
    })
    wx.request({
      url: 'https://www.citycreate.cn/bbj/wx/course/list.html',
      data: {
        pageNo: 1,
        pageSize: 4,
      },
      success:(item)=>{
        this.setData({
          kechengArray:item.data.data.list  
        })
      }
    })
    wx.request({
      url: 'https://www.citycreate.cn/bbj/wx/teacher/list.html',
      data: {
        pageNo: 1,
        pageSize: 4,
      },
      success: (item) => {
        this.setData({
          teacherArray: item.data.data.list
        })
      }
    })
  },
  to:function(e){
    wx.navigateTo({
      url: '../' + e.currentTarget.id+'/kecheng',
    })
  },
  toYuYue:function(e){
    wx.navigateTo({
      url: '../yuyue/yuyue',
    })
  },
  tokecheng:function(){
    wx.switchTab({
      url: '../kecheng/kecheng'
    })
  },
  toTeacher:function(){
    wx.switchTab({
      url: '../teacher/teacher'
    })
  },
  toKeChengDetail(item){
    wx.navigateTo({
      url: '../kechengDetail/kecheng?id=' + item.currentTarget.id,
    })
  },
  toTeacherDetail(item){
    wx.navigateTo({
      url: '../teacherDetail/about?id=' + item.currentTarget.id,
    })
  },
  toActivityDetail(item){
    wx.navigateTo({
      url: '../activityDetail/kecheng?id=' + item.currentTarget.id,
    })
  },
  toZhiXunDetail(item) {
    wx.navigateTo({
      url: '../zixunDetail/kecheng?id=' + item.currentTarget.id,
    })
  },
  toSwiper(e){
    let array = e.currentTarget.id.split('|')
    console.log(array)
    if(array[1]=='0'){
      wx.navigateTo({
        url: '../activityDetail/kecheng?id=' + array[0],
      })
    }else if(array[1]=='1'){
      wx.navigateTo({
        url: '../zixunDetail/kecheng?id=' + array[0],
      })
    } else if (array[1] == '2') {
      wx.navigateTo({
        url: '../teacherDetail/about?id=' + array[0],
      })
    } else if (array[1] == '3') {
      wx.navigateTo({
        url: '../kechengDetail/kecheng?id=' + array[0],
      })
    }
  }
})
